package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.TravelBaseBabel;
import cn.source.system.service.ITravelBaseBabelService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 基地标签Controller
 *
 * @author sourcebyte.vip
 * @date 2024-06-18
 */
@RestController
@RequestMapping("/travel/baseBabel")
public class TravelBaseBabelController extends BaseController
{
    @Autowired
    private ITravelBaseBabelService travelBaseBabelService;

    /**
     * 查询基地标签列表
     */
    @PreAuthorize("@ss.hasPermi('travel:baseBabel:list')")
    @GetMapping("/list")
    public TableDataInfo list(TravelBaseBabel travelBaseBabel)
    {
        startPage();
        List<TravelBaseBabel> list = travelBaseBabelService.selectTravelBaseBabelList(travelBaseBabel);
        return getDataTable(list);
    }

    /**
     * 获取基地标签详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(travelBaseBabelService.selectTravelBaseBabelById(id));
    }

    /**
     * 新增基地标签
     */
    @PreAuthorize("@ss.hasPermi('travel:baseBabel:add')")
    @Log(title = "基地标签", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TravelBaseBabel travelBaseBabel)
    {
        return toAjax(travelBaseBabelService.insertTravelBaseBabel(travelBaseBabel));
    }

    /**
     * 修改基地标签
     */
    @PreAuthorize("@ss.hasPermi('travel:baseBabel:edit')")
    @Log(title = "基地标签", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TravelBaseBabel travelBaseBabel)
    {
        return toAjax(travelBaseBabelService.updateTravelBaseBabel(travelBaseBabel));
    }

    /**
     * 删除基地标签
     */
    @PreAuthorize("@ss.hasPermi('travel:baseBabel:remove')")
    @Log(title = "基地标签", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(travelBaseBabelService.deleteTravelBaseBabelByIds(ids));
    }

    /**
     * 导出基地标签列表
     */
    @PreAuthorize("@ss.hasPermi('travel:baseBabel:export')")
    @Log(title = "基地标签", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TravelBaseBabel travelBaseBabel)
    {
        List<TravelBaseBabel> list = travelBaseBabelService.selectTravelBaseBabelList(travelBaseBabel);
        ExcelUtil<TravelBaseBabel> util = new ExcelUtil<TravelBaseBabel>(TravelBaseBabel.class);
        util.exportExcel(response, list, "基地标签数据");
    }
}
